<?php
class GearmanCommand extends BaseCommand
{
    public function actionStart()
    {
        $worker = Yii::app()->gearman->worker();
        
        $jobs = require(Yii::getPathOfAlias('application.config').'/gearman.php');
        foreach($jobs as $name => $job)
        {
            $worker->addFunction((string)$name, array($job[ENUM_GEARMAN_WORKER].'Worker', $job[ENUM_GEARMAN_ACTION]));
        }
        
        while($worker->work()) {}
    }
}